\pard\tx3120\tx3620\tx4120\fs28\li2620 ErrorInfo is a class designed to be used as the return value from the method of some other object. That is, instead of merely returning a numeric code reflecting the error state, an object would return an ErrorInfo object. An ErrorInfo object contains more than just an error code, and therefore should be more usefull to the code that called the method than a simple number.\
\fs16 \
\fs28 The ErrorInfo object is designed to be a minimal set of error information, and it is expected that some applications will need to subclass it to provide more specialized information than ErrorInfo does.\
\fs16 \
\fs28 ErrorInfo keeps three instance variables: a flag indicating what kind of error this is reporting, an error code, and a null C string describing the error. The values of the string and code are error specific, and are not dictated by the object. There are three kinds of error kind flags defined as part of the object: ERRKIND_GENERAL, ERRKIND_OS, and ERRKIND_USER. The first is the one that is used by default. An errKindOS indicates that the error code being returned is from an operating system problem (e.g. an error code when trying to call
\b fopen()
\b0 ). The final might be used when an error is being reported based on a user's actions (e.g. the user clicked on an object they shouldn't have).\
\fs16 \
\fs28 ErrorInfo provides methods to access each of these values, a method to free the object, and two creation methods. Note that the creation methods are the only way to store values in the error object.\
\fs16 \
\fs28 Using an ErrorInfo object is straightforward. A method might create an ErrorInfo object using newErrorWithCode:Text:Kind:, and then merely return it to the caller. The caller, in turn, might retrieve the error text using getErrorText and then free the object.\
\fs16 \
\b\fs28 Note:
\b0 by convention, a method that returns an ErrorInfo object will return a nil object pointer if there were no errors.\
\fs16 \
\pard\tx7140\li2100 \
\
\fs28 INSTANCE VARIABLES\
\fs16 \
\pard\tx6640\tx9660\tx10180\i\fs28\fi-4040\li6640 Inherited from Object
\pard\tx3120\tx3620\tx4120\b0\fs28\li2620 Creates a new ErrorInfo object, assigning the values of code, kind and text to its instance variables. Note that the entire text is duplicated, not just the pointer. \
\pard\tx7140\fs16\li2100 \
\b \
\fs28 initErrorWithCode:Text:\
\pard\b0\fi-1020\li3620 - (id)
\b initErrorWithCode:
\b0 (long int)
\i code
\b\i0 Text:
\b0 (Cstring)
\i text
\b\i0 \
\fs16 \
\pard\tx3120\tx3620\tx4120\b0\fs28\li2620 Calls
\b newErrorWithCode:Text:Kind:
\b0 using errKindGeneral for the
\i kind
\i0 parameter. This, then, simply serves as a more common case wrapper around the preceeding method.\
\pard\tx7140\fs16\li2100 \
\b \
\fs28 free\
\pard\b0\fi-1020\li3620 -
\b free\
\fs16 \
\pard\tx3120\tx3620\tx4120\b0\fs28\li2620 Disposes of the instance values of the method and frees the object..\
\pard\tx7140\fs16\li2100 \
\b \
\fs28 getErrorKind\
\pard\f1\b0\fi-1020\li3620 -
\f0 (long int)
\b getErrorKind\
\fs16 \
\pard\tx3120\tx3620\tx4120\b0\fs28\li2620 Returns the kind of the error object (see constants, below, for a list of kinds).\
\fs16 \
\pard\tx7140\b\li2100 \
\fs28 getErrorText\
\pard\f1\b0\fi-1020\li3620 -
\f0 (Cstring)
\b getErrorText\
\fs16 \
\pard\tx3120\tx3620\tx4120\b0\fs28\li2620 Returns a copy of the text of the error object to the caller. Note that this means that the caller is responsible for disposing the text at their leisure.\
\fs16 \
\pard\tx7140\b\li2100 \
\fs28 getErrorCode\
\pard\f1\b0\fi-1020\li3620 -
\f0 (long int)
\b getErrorCode\
\fs16 \
\pard\tx3120\tx3620\tx4120\b0\fs28\li2620 Returns the error code stored in the object.\
\fs16 \
\pard\tx7140\li2100 \
\
\fs28 BUGS AND PROBLEMS\
\fs16 \
\pard\tx3120\tx3620\tx4120\fs28\li2620 If the caller wants controll over where the string returned by getErrorText is allocated, they're up the proverbial creek.\
\fs16 \
\pard\tx7140\li2100 \
\
\fs28 ENHANCEMENT IDEAS\
\fs16 \
\pard\tx3120\tx3620\tx4120\fs28\li2620 none\
\fs16 \
\pard\tx7140\li2100 \
\
\fs28 CONSTANTS AND DEFINED TYPES\
\fs16 \
\pard\tx6480\tx7180\fs24\li2620 /* ErrInfo kinds of errors */\
#define ERRKIND_NONE 0 // Do not use this kind. Return NULL instead.\
\pard\tx3120\tx3620\tx4120\fs28\li2620 $Log: ErrorInfo.rtf,v $Revision 1.2 92/02/09 18:43:55 deathRremoved listed bug that stated that no error checking was being done. All reasonable checking is now being done.\
@
1.2
log
@Rremoved listed bug that stated that no error checking was being done. All reasonable checking is now being done.